﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditAlbara.aspx.cs" Inherits="Vista.Gestio.EditAlbara"
    MasterPageFile="~/Gestio/GestioMasterPage.master" %>

<%@ MasterType VirtualPath="~/Gestio/GestioMasterPage.master" %>

<%@ Register Src="~/Controls/ModalPanel.ascx" TagPrefix="ctrl" TagName="Modal" %>
<%@ Register Src="~/Controls/Carregant.ascx" TagPrefix="ctrl" TagName="Carregant" %>

<asp:Content ID="bodyEditAlbara" runat="server" ContentPlaceHolderID="privateCPHBody">
    <asp:UpdatePanel ID="upEditAlbara" runat="server" Visible="true" UpdateMode="Conditional">
        <ContentTemplate>
                    <%--Capçalera de l'Albarà--%>
            <asp:Label id="lblTitulEditAlbara" CssClass="classTitul" Text="Editar Albarà: " runat="server" />
            <label class="classTitul" style="margin-left:410px;">Fecha: </label>
            <asp:TextBox ID="tbData"  CssClass="classTitul" runat="server" style="float:right; margin-right:50px" />
            <br />
            <br />
            <label style="float:left; margin-left:15px;">Albaran nº: </label>
            <asp:Label ID="lblAlbara" runat="server" style="float:left; margin-right:12px; margin-left:65px;" width="150px" />
            <asp:Label ID="lblNCliente" runat="server" Text="Nº Cliente: " style="float:right; margin-right:300px"  />
            <br />
            <label style="float:left; clear:both; margin-left:15px;">Nº Orden: </label>
            <asp:Label ID="lblOrdre" runat="server"  style="float:left; margin-right:12px; margin-left:65px;" width="150px" />
            <asp:Label ID="lblCliente" runat="server" Text="Cliente: " Style="float: right; margin-right: 300px" />
            <asp:DropDownList ID="ddlClient" runat="server" Style="float: right; margin-right: -210px" Width="150px"
                AutoPostBack="true" OnTextChanged="ddlClient_TextChanged" 
                DataSourceID="odsClient" DataTextField="NomClient" DataValueField="IdClient"/>
            <%--Carrega l'objecte client des de negoci--%>
            <asp:ObjectDataSource ID="odsClient" runat="server" DataObjectTypeName="DeltaFlex.Negoci.Client"
                SelectMethod="LlistarClientByIDClient" TypeName="DeltaFlex.Negoci.Client">
                <SelectParameters>
                    <asp:QueryStringParameter Name="idClient" QueryStringField="empid" DefaultValue="0" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <br />
            <asp:Label ID="lblPedido" runat="server" Text="Nº Pedido: " style="float:left; margin-left:15px;" width="130px" />
            <asp:TextBox ID="tbPedido" runat="server" style="float:left;"  />
            <asp:Label ID="lblDireccion" runat="server" Text="&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;" style="float:right; margin-right:150px"  />
            <br />
            <asp:Label ID="lblReferencia" runat="server" Text="Referencia: " style=" clear:both; float:left; margin-left:15px;" width="130px" />
            <asp:TextBox ID="tbReferencia" runat="server" style="float:left;" />
            <asp:Label ID="lblCiudad" runat="server" Text="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" style="float:right; margin-right:150px" />
            <br />
            <asp:Label ID="lblTrabajo" runat="server" Text="Id. Trabajo: " style="float:left; clear:both; margin-left:15px;" width="130px" />
            <asp:TextBox ID="tbTrabajo" runat="server" style="float:left;"  />
            <asp:Label ID="lblProvincia" runat="server" Text="&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;" style="float:right; margin-right:150px"  />
            <br />
            <asp:Label ID="lblTroquel" runat="server" Text="Número Troquel: " style="float:left; clear:both; margin-left:15px;" width="130px" />
            <asp:TextBox ID="tbTroquel" runat="server" style="float:left;" />
            <asp:Label ID="lblTelf" runat="server" Text="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" style="float:right; margin-right:150px"  />
            <br />
            <br />
            <div class="classRatllaSepara"> </div>
            <br />
            <div class="classRatllaSepara"> </div>
            <br />
            <%--Conceptes de l'Albarà--%>
            <asp:ObjectDataSource ID="odsEditConcepteAlbara" runat="server" TypeName="DeltaFlex.Negoci.Concepte_Albara" 
            SelectMethod="LlistarConcepte_Albarans" UpdateMethod="ActualitzarConcepteAlbara">
                <SelectParameters>
                    <asp:ControlParameter ControlID="lblAlbara" Name="IdAlbara" PropertyName="Text" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <asp:GridView ID="gvEditConcepteAlbara" AutoGenerateColumns="false" runat="server"
                DataSourceID="odsEditConcepteAlbara" Width="910px" OnRowUpdating="gvEditConcepteAlbara_RowUpdating"
                OnRowDataBound="gvEditConcepteAlbara_RowDataBound" >
                <Columns>
                    <%--<asp:CommandField ShowDeleteButton="false" ShowEditButton="true" HeaderText="Editar"
                        UpdateText="Actualitzar" UpdateImageUrl="~/Imatges/editar_Grid.png" HeaderStyle-Width="50px" />--%>
                    <asp:TemplateField HeaderText="IdConcepteAlbara" Visible="false" >
                        <ItemTemplate>
                            <asp:Label ID="lblIdConcepteAlbara" runat="server" Text='<%# Bind("IdConcepte_Albara") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IdAticle" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblIdArticle" runat="server" Text='<%# Bind("Article.IdArticle") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ref.Article" Visible="true" HeaderStyle-Width="75px">
                        <ItemTemplate>
                            <asp:Label ID="lblrefArticle" runat="server" Text='<%# Bind("BindRefArticle") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Concepte" Visible="true" HeaderStyle-Width="100px">
                        <ItemTemplate>
                            <asp:Label ID="lblConcepte" runat="server" Text='<%# Bind("BindConcepte") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlConcepte" runat="server" DataSourceID="odsArticles" 
                                DataTextField="NomArticle" DataValueField="IdArticle" />
                            <%--Carrega l'objecte Articles des de negoci--%>
                            <asp:ObjectDataSource ID="odsArticles" runat="server" DataObjectTypeName="DeltaFlex.Negoci.Articles"
                                SelectMethod="LlistaTotsArticles" TypeName="DeltaFlex.Negoci.Articles" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Quantitat" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lblQuantitat" runat="server" Text='<%# Bind("Quantitat") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbQuantitat" runat="server" Text='<%# Bind("Quantitat") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Mesures" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lblStrSuperficie" runat="server" Text='<%# Bind("StrSuperficie") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbStrSuperficie" runat="server" Text='<%# Bind("StrSuperficie") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Superficie" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lblDecimalSuperficie" runat="server" Text='<%# Bind("DecimalSuperficie") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbDecimalSuperficie" runat="server" Text='<%# Bind("DecimalSuperficie") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Unitats" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lbUnitats" runat="server" Text='<%# Bind("Unitats") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbUnitats" runat="server" Text='<%# Bind("Unitats") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="PVP" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lblpvp" runat="server" Text='<%# Bind("BindPVP") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbpvp" runat="server" Text='<%# Bind("Pvp") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Import" Visible="true" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="lblImport" runat="server" Text='<%# Bind("BindImport") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbImport" runat="server" Text='<%# Bind("Import") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <asp:Button ID="Button1" OnClick="btnTornar_Click" Text="Tornar" ToolTip="Tornar al llista d'albarans"
                runat="server" CausesValidation="false" CssClass="classBotonsDreta" Style="margin-right: 5%" />
            <asp:Button ID="btnEditarAlbara" OnClick="btnEditarAlbara_Click" Text="Guardar" ToolTip="Actualitzar Albarà"
                runat="server" CausesValidation="false" CssClass="classBotonsDreta" />
            <asp:Button ID="btnImprimir" OnClick="btnImprimir_Click" Text="Imprimir" ToolTip="Imprimir Albarà"
                runat="server" CausesValidation="false" CssClass="classBotonsDreta" />
            <br />

            <%--Crida al control Modal--%>
            <ctrl:Modal ID="mpEditarAlbara" runat="server" />
        </ContentTemplate>
        <Triggers>
        <asp:PostBackTrigger ControlID="btnImprimir" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
